@include('admin._include.header')

<body>

<div class="layui-fluid">
    <div class="larry-container">
        <div class="layui-row layui-col-space15 larryms-data-top">
            <div class="layui-col-xs12 layui-col-sm12 layui-col-md12 layui-col-lg12">

                <form action="" class="layui-form">
                    <div class="layui-form-item">

                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input  id="name" placeholder="昵称/手机号" autocomplete="off" class="layui-input"/>
                            </div>
                            <button type="button" class="layui-btn" id="search">确定</button>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">用户级别</label>
                            <div class="layui-input-inline">
                                <select name="status" lay-verify="required" lay-filter="status" lay-search="">
                                    <option value="">全部</option>
                                    <option value="1">普通会员</option>
                                    <option value="2">经销商</option>
                                    <option value="3">合伙人</option>

                                </select>
                            </div>
                        </div>

                    </div>
                </form>

                <table lay-filter="ad_table" class="layui-table" lay-data="{height:'full-155',cellMinWidth:95,url:'{{url('user/user-list')}}', page:true, id:'ad_table',defaultToolbar:[]}">
                    <thead>
                    <tr>
                        <th lay-data="{field:'id',align:'center'}">ID</th>
                        <th lay-data="{toolbar:'#toolbarDemo',width:80,align:'center'}">头像</th>
                        <th lay-data="{field:'nick_name',align:'center'}">昵称</th>
                        <th lay-data="{field:'sex_string',align:'center'}">性别</th>
                        <th lay-data="{field:'mobile',align:'center'}">手机号</th>
                        <th lay-data="{field:'balance',align:'center'}">余额</th>
                        <th lay-data="{field:'level_string',align:'center'}">用户级别</th>
                        <th lay-data="{field:'pid_string',align:'center'}">上级</th>
                        <th lay-data="{field:'create_at',align:'center'}">创建时间</th>
                        <th lay-data="{title:'操作',templet:'#listBar',align:'center'}">操作</th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="toolbarDemo" class="layer-photos-demo">
    <img src="@{{ d.avatar }}" width="20px" height="20px" layer-src="@{{ d.avatar }}" alt="" lay-event="show">
</script>

<script type="text/html" id="listBar">
    <a class="layui-btn layui-btn-xs"  data-url="{{url('user/detail')}}/@{{ d.id }}" lay-event="edit">详情</a>
    <a class="layui-btn-warm layui-btn layui-btn-xs"  data-url="{{url('user/balance-log')}}/@{{ d.id }}" lay-event="balance">余额流水</a>
</script>

<script>
    layui.config({
        base: "/plugin/layuiadmin/"  //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function(){
        var $ = layui.$,
            form = layui.form,
            table = layui.table;

        form.on('select(status)', function(data) {
            table.reload('ad_table', {
                where:{
                    level:data.value
                }
            });
        });

        $("#search").on('click', function () {
            table.reload('ad_table', {
                where:{
                    name:$("#name").val()
                }
            });
        });

        table.on('tool(ad_table)', function(obj){
            var data = obj.data;
            var that = this;
            var url = $(this).data('url');

            switch (obj.event) {
                case "show":
                    var arr = [];
                    var obj = {
                        'alt':data.avatar,
                        'pic':data.id+"_id",
                        'src':data.avatar,
                        'thumb':data.avatar
                    };
                    arr.push(obj);
                    var json = {
                        'title':data.avatar,
                        'id':data.id,
                        'start':0,
                        'data':arr
                    };
                    layer.photos({
                        photos: json
                        ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                    });
                    break;

                case 'edit':
                    var index = layer.open({
                        title: '详情',
                        type: 2,
                        area: ['760px', '550px'],
                        content: url,
                        end: function() {
                            $(that).removeAttr("data-flag");
                            layui.cache.layerIndex = null;
                            table.reload('ad_table')
                        }
                    });
                    layer.full(index);
                    break;

                case 'balance':
                    var index = layer.open({
                        title: '余额流水记录',
                        type: 2,
                        area: ['600px', '550px'],
                        content: url,
                        end: function() {
                            $(that).removeAttr("data-flag");
                            layui.cache.layerIndex = null;
                            table.reload('ad_table')
                        }
                    });
                    break;

                default:
                    break;

            }

        });

    });

</script>
</body>

@include('admin._include.footer')


